import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'path';
import postCssPxToRem from "postcss-pxtorem"

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: [
      { find: '@assets', replacement: resolve(__dirname, 'src/assets') },
      { find: '@runtime', replacement: resolve(__dirname, 'src/runtime') },
      { find: '@components', replacement: resolve(__dirname, 'src/components') },
    ]
  },
  build: {
    rollupOptions: {
      output:{
        manualChunks(id) {
            if (id.includes('components')) { // 把 components 文件里面的文件都打包到 components.js 中 
                return 'components'
            }
        }
    }},
    // outDir: 'D:/打包文件',
    // outDir: 'D:/运行环境/P10064/UI',
    outDir: 'D:/运行环境/P10079/UI',
    emptyOutDir: true,
    assetsDir: 'assets',
    // minify:false,
  },
  server: {
    cors: true,
    host: "127.0.0.1",
    open: true
  },
  css: {
    postcss: {
      plugins: [
        postCssPxToRem({
          rootValue: 192, // 1rem的大小
          propList: ['*'], // 需要转换的属性，这里选择全部都进行转换
        })
      ]
    }
  },
})
